package com.beyondsoft.dtc.mobile.automation.util;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.time.format.DateTimeFormatter;
import java.util.Date;

public class ExlFileUtil {

	public static void saveInfo(String taskId, String deviceSign,
			String why) {

		try {
			File file = new File("/code/test/ng_device.xls");
			if (!file.exists()) {
				file.createNewFile();
				BufferedWriter bfw = new BufferedWriter(new FileWriter(file));
				bfw.write("date,task_id,serial_number,case_by\n");
				bfw.close();
			}
			BufferedWriter bfw = new BufferedWriter(new FileWriter(file, true));
			//noinspection deprecation
			bfw.write(new Date().toGMTString() + "," + taskId + "," + deviceSign + "," + why + "\n");
			bfw.close();

		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
